import requests


# UA伪装
headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36'
}
url = 'http://www.kfc.com.cn/kfccda/ashx/GetStoreList.ashx?op=cname'

data = {
    'cname': '北京',
    'pageIndex': 1,
    'pageSize': 10
}

response = requests.post(url,headers= headers,data=data)
# print(type(response.text))
ctcount = response.json()['Table'][0]['rowcount']
ct_list = response.json()['Table1']

#请求的页数
pages = ctcount//10 +1

for page in range(2,pages+1):
    data = {
    'cname': '北京',
    'pageIndex': page,
    'pageSize': 10
    }
    response = requests.post(url,headers= headers,data=data)
    new_list = response.json()['Table1']
    ct_list.extend(new_list)
print (ct_list)
